package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.ShopCart;
import com.weipai.springboot.module.dao.ShopCartDao;
import com.weipai.springboot.module.mapper.ShopCartMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/27 15:50
 */
@Repository
public class ShopCartDaoImpl implements ShopCartDao{

    @Autowired
    ShopCartMapper shopCartMapper;
    
    //加入购物车
    @Override
    public int addToShopCart(ShopCart shopCart) {
        return shopCartMapper.insertSelective(shopCart);
    }

    //购物车商品
    @Override
    public List<Map<String, Object>> shopCartList(String customerId) {
        return shopCartMapper.shopCartList(customerId);
    }

    //删除购物车商品
    @Override
    public int deleteShopCartById(Integer id) {
        return shopCartMapper.deleteByPrimaryKey(id);
    }

    //删除
    @Override
    public int deleteById(String customerId, String goodsId) {
        return shopCartMapper.deleteById(customerId, goodsId);
    }

    @Override
    public int vertifiData(String customerId, String goodsId) {
        return shopCartMapper.vertifiData(customerId,  goodsId);
    }

    @Override
    public ShopCart selectByCustomerIdAndGoodsId(String customerId, String goodsId) {
        return shopCartMapper.selectByCustomerIdAndGoodsId(customerId, goodsId);
    }

    @Override
    public int updateByPrimaryKeySelective(ShopCart shopCart1) {
        return shopCartMapper.updateByPrimaryKeySelective(shopCart1);
    }
}
